package at.codebase.web.servlets.user;

import static at.codebase.web.util.i18n.I18NFactory.i18n;

import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;

import at.codebase.web.templates.MainTemplate;
import at.codebase.web.templates.UserProfileTemplate;
import at.codebase.web.util.LocalRequest.RequestInformation;
import at.codebase.web.util.template.Template;
import at.codebase.web.util.template.TemplateEngine;

/**
 * 
 * @author Lukas Pfeifhofer <lukas.pfeifhofer@devlabs.pro>
 *
 */
public class UserUpload extends AUserProfile {
	
	private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
	
	@Override
	void buildUserPage(MainTemplate mainTemplate, UserProfileTemplate userProfileTemplate, RequestInformation requestInfo, UserLevel level, RequestType requestType) {
		mainTemplate.setTitle(i18n(requestInfo.getLocale()).string("userUpload_header"));
		mainTemplate.addJSScript("script_user_upload.js");
		
		Template userUploadT = TemplateEngine.getTemplate("user/site_profile_upload.html");
		userUploadT.setText("uploadUrl", blobstoreService.createUploadUrl("/user/userUploadHandler"));
		
		userProfileTemplate.setContent(userUploadT);
	}

}